package com.zr.java8.pattern.state.impl;

import com.zr.java8.pattern.state.OrderContext;
import com.zr.java8.pattern.state.OrderState;

// 已发货状态
public class ShippedState implements OrderState {
    @Override
    public void pay(OrderContext context) {
        System.out.println("错误：订单已发货，无需支付！");
    }

    @Override
    public void ship(OrderContext context) {
        System.out.println("错误：订单已发货，无需重复发货！");
    }

    @Override
    public void complete(OrderContext context) {
        // 已发货状态下可以完成，完成后切换到已完成状态
        System.out.println("订单完成！");
        context.setState(new CompletedState()); // 状态切换
    }

    @Override
    public String getStateName() {
        return "已发货";
    }
}
